@use '../utils/box-shadow_variables';
@use '../utils/mixins';
@use '../utils/size_variables';
@use '../core/buttons.scss';

/**
 * Copyright (c) HashiCorp, Inc.
 * SPDX-License-Identifier: BUSL-1.1
 */

.tabs-container + .toolbar {
  border-top: 0;
}

.toolbar {
  background-color: var(--token-color-palette-neutral-50);
  border: 1px solid var(--token-color-palette-neutral-100);
  border-bottom-color: var(--token-color-palette-neutral-300);
  border-top-color: var(--token-color-palette-neutral-300);
  position: relative;

  &::after {
    background: linear-gradient(
      to right,
      var(--token-color-palette-neutral-50),
      rgba(var(--token-color-palette-neutral-50), 0)
    );
    bottom: 0;
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: size_variables.$spacing-4;
    z-index: 2;
  }

  .input,
  .select {
    min-width: max-content;
  }
}

.toolbar-label {
  padding: size_variables.$spacing-8;
  color: var(--token-color-palette-neutral-400);
}

.toolbar-scroller {
  align-items: center;
  display: flex;
  height: 3rem;
  justify-content: space-between;
  width: 100%;

  @include mixins.from(size_variables.$mobile) {
    padding: 0 size_variables.$spacing-4;
  }

  &::-webkit-scrollbar {
    border-bottom: box-shadow_variables.$base-border;
    height: size_variables.$spacing-4;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--token-color-palette-neutral-300);
    border-radius: size_variables.$spacing-4;
  }
}

.toolbar-filters,
.toolbar-actions {
  align-items: center;
  display: flex;
  flex: 1;
  white-space: nowrap;
  &:has(.hds-modal) {
    // toolbar buttons that open/close a modal pass attrs to the modal content
    white-space: wrap;
  }
}

.toolbar-filters + .toolbar-actions {
  @include mixins.until(size_variables.$mobile) {
    border-left: box-shadow_variables.$base-border;
    margin-left: size_variables.$spacing-8;
    padding-left: size_variables.$spacing-8;
  }
}

.toolbar-actions {
  @include mixins.from(size_variables.$mobile) {
    justify-content: flex-end;
  }
}

.toolbar-link {
  @extend .button;
  @extend .is-ghost;
  @extend .has-icon-right;
  border: 0;
  color: hsl(0, 0%, 4%);
  transition: background-color size_variables.$speed;

  &:hover:not(.disabled) {
    background-color: var(--token-color-palette-neutral-100);
    border: 0;
    color: var(--token-color-palette-blue-200);
  }

  &:active {
    box-shadow: none;
  }

  &.popup-menu-trigger {
    height: 2.5rem;
    padding: size_variables.$spacing-8 size_variables.$spacing-12;
  }

  &.disabled {
    opacity: 0.5;
    cursor: default;

    &:focus {
      box-shadow: none;
    }
    &:hover {
      background: transparent;
    }
  }
}
a.disabled.toolbar-link {
  color: hsl(0, 0%, 4%);
  background-color: hsl(0, 0%, 100%);
  cursor: not-allowed;
  &:hover {
    background-color: var(--token-color-palette-neutral-100);
    color: var(--token-color-palette-blue-200);
  }
}

.toolbar-separator {
  border-right: box-shadow_variables.$light-border;
  height: 32px;
  margin: 0 size_variables.$spacing-8;
  width: 0;
}

.segment-filter {
  width: min-content;
}
